﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using GoodMan.Infrastructure.Entities.Repository;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class Integration : IAccessible<T_Integration, Integration>, ILogicEntity<T_Integration, Integration>
    {
        public string UserName { get; set; }
        public int Activity { get; set; }
        public int CostValue { get; set; }
        public decimal Balance { get; set; }
        public decimal LockBalance { get; set; }

        protected override void Covariant(T_Integration model)
        {
            if (model != null)
            {
                this.UserName = model.UserName;
                this.Activity = model.Activity;
                this.CostValue = model.CostValue;
                this.Balance = model.Balance;
                this.LockBalance = model.LockBalance;
            }
        }

        protected override T_Integration Inverter(Integration model)
        {
            if (model != null)
            {
                return new T_Integration()
                {
                    Activity = model.Activity,
                    Balance = model.Balance,
                    CostValue = model.CostValue,
                    UserName = model.UserName,
                    LockBalance=model.LockBalance
                };
            }
            return null;
        }

        public Integration Set(T_Integration dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
